<p>This rule raises an issue when checking if any array element matches a condition using <code>.filter().length</code>, <code>.find()</code>,
<code>.findLast()</code>, <code>.findIndex()</code>, or <code>.findLastIndex()</code> instead of the more appropriate <code>.some()</code> method.</p>
<h2>Why is this an issue?</h2>
<p>JavaScript’s <code>Array.prototype.some()</code> method is specifically designed to test whether at least one element in an array passes a provided
test function. Using other array methods for this purpose creates several problems:</p>
<p><strong>Semantic clarity</strong>: Methods like <code>.filter().length &gt; 0</code> or <code>.find() !== undefined</code> obscure the intent. When
you read <code>.some(condition)</code>, it’s immediately clear that you’re checking for existence. Other patterns require mental parsing to understand
the purpose.</p>
<p><strong>Performance implications</strong>: <code>.filter()</code> processes the entire array and creates a new array, even when you only need to
know if one element matches. <code>.some()</code> short-circuits and stops as soon as it finds the first matching element, making it more efficient
for large arrays.</p>
<p><strong>Code maintainability</strong>: Using the wrong method for the job makes code harder to understand and maintain. Future developers
(including yourself) need to spend extra time understanding why a more complex pattern was chosen over the straightforward <code>.some()</code>
method.</p>
<p><strong>Consistency</strong>: Using the semantically correct method makes your codebase more consistent and follows JavaScript best practices,
improving overall code quality.</p>
<h3>What is the potential impact?</h3>
<p>Using inappropriate array methods for existence checking reduces code readability and can impact performance, especially with large arrays. While
not a security issue, it makes code harder to maintain and understand, potentially leading to bugs during refactoring or when other developers work
with the code.</p>
<h3>How to fix?</h3>
<p>Replace <code>.filter().length</code> checks with <code>.some()</code> to test for element existence. This is more readable and efficient since
<code>.some()</code> stops at the first match.</p>
<h4>Non-compliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
const hasUnicorn = array.filter(element =&gt; isUnicorn(element)).length &gt; 0; // Noncompliant
const hasMatch = items.filter(item =&gt; item.active).length !== 0; // Noncompliant
</pre>
<h4>Compliant code example</h4>
<pre data-diff-id="1" data-diff-type="compliant">
const hasUnicorn = array.some(element =&gt; isUnicorn(element));
const hasMatch = items.some(item =&gt; item.active);
</pre>
<h3>Documentation</h3>
<ul>
  <li> <a href="https://github.com/sindresorhus/eslint-plugin-unicorn#readme">eslint-plugin-unicorn</a> - Rule <a
  href="https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prefer-array-some.md">prefer-array-some</a> </li>
  <li> MDN - Array.prototype.some() - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some">Official
  documentation for the Array.some() method</a> </li>
  <li> MDN - Array.prototype.filter() - <a
  href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter">Official documentation for the Array.filter()
  method</a> </li>
  <li> MDN - Array.prototype.find() - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find">Official
  documentation for the Array.find() method</a> </li>
</ul>
